package com.share.algorithm.sort;

/**
 * @desc:选择排序
 * @author:caifan
 * @date:2020/9/24
 */
public class SelectSort {

    public static void main(String[] args) {
        int[] arrs = new int []{3, 6, 8, 2, 9, 10};
        selectSort(arrs);
        for (int i=0;i<arrs.length;i++) {
            System.out.println(arrs[i]);
        }
    }

    public static int[] selectSort(int[] array) {
        for (int i=0;i<array.length;i++) {
            for (int j=0;j<array.length;j++) {
                if (array[i] > array[j]) {
                    int temp;
                    temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }
        }
        return array;
    }
}
